package discov

import (
	"log"
)

type Discover interface {
	Endpoint() (string, error)
}

func MustNewDiscover(conf Conf) Discover {
	d, err := NewDiscover(conf)
	if err != nil {
		log.Fatalf("%+v", err)
	}
	return d
}

func NewDiscover(conf Conf) (Discover, error) {
	if !conf.valid() {
		return nil, ConfValidErr
	}

	if conf.Discover == DIRECT_DISCOVER {
		return NewDirectDiscover(conf)
	}
	return NewConsulDiscover(conf)
}
